package org.mycub.server.mongodb;

import org.mycub.server.data.models.BusStation;
import org.mycub.server.data.models.FreeParking;
import org.mycub.server.data.models.InternetAccess;
import org.mycub.server.data.models.PaidParking;
import org.mycub.server.data.models.PublicToilet;
import org.mycub.server.data.models.TramStation;
import org.mycub.server.data.models.VCUBStation;

import com.google.code.morphia.Datastore;
import com.google.code.morphia.Morphia;
import com.mongodb.Mongo;

public class MongoDB {
	
	private int PORTVALUE = 27017;
	private String DBNAME = "mycubDB";
	
	public static Mongo mongo ;
	public static Morphia morphia;
	public static Datastore dataStore;
	
	public MongoDB() throws Exception {
			mongo = new Mongo("localhost", PORTVALUE);
	}
	
	public void connect(){
		morphia = new Morphia();
		dataStore = morphia.createDatastore(mongo, DBNAME);
		// TODO Ajouter les modèles
		morphia.map(TramStation.class);
		morphia.map(BusStation.class);
		morphia.map(VCUBStation.class);
		morphia.map(FreeParking.class);
		morphia.map(PaidParking.class);
		morphia.map(InternetAccess.class);
		morphia.map(PublicToilet.class);
		
		dataStore.ensureIndexes();
	}
	
}
